import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import router from "@/router/index"
export const useRoutesStore = defineStore('routes', () => {
  
  const routes=ref([])

  function AddRoute(route){
    routes.value.push(route)
  }


  function removeAll(){
    //进行退出操作，清空所有路由
    routes.value.forEach((route)=>{
      router.removeRoute(route.name)
    })
    routes.value=[]
  }

  return { 
    routes,
    AddRoute,
    removeAll
   }
},{
  persist: true,
},)
